<template>
	<view class="m-radio-view" :style="[getStyleComputed]" @click="clickFun">
		<view class="" v-show="value">
			<u-icon name="checkbox-mark" size="26" :color="color"></u-icon>
		</view>
	</view>
</template>

<script>
	export default {
		name:"m-radio",
		props:{
			value:{
				type:Boolean,
				default:false
			},
			index:{
				type:Number,
				default:0
			},
			width:{
				type:Number,
				default:37
			},
			height:{
				type:Number,
				default:37
			},
			disabled:{
				type:Boolean,
				default:false
			},
			color:{
				type:String,
				default:"#fff"
			},
			bgColor:{
				type:String,
				default:"#D3A358"
			},
		},
		data() {
			return {
				
			}
		},
		computed:{
			getStyleComputed(){
				let _style = {}
				_style.width = this.width + 'rpx'
				_style.height = this.height + 'rpx'
				_style.color = this.color
				if(this.value){
					_style.background = this.bgColor
					_style.border = `1px solid ${this.bgColor}`
				}
				return _style
			}
		},
		created() {
			
		},
		methods:{
			clickFun(){
				if(this.disabled) return ;
				this.$emit('input',!this.value)
				this.$emit('change',!this.value,this.index)
			}
		}
		
	}
</script>

<style scoped lang="scss">
.m-radio-view{
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50%;
		border: 1px solid #BFBFBF;
		border-radius: 50%;
	}
</style>